package com.logistics.socket.model;

import com.logistics.utils.tool.DateUtils;
import lombok.Data;
import org.apache.commons.lang.math.RandomUtils;

import java.util.Date;

@Data
public class RequestSocketModel {

    private Integer reqCode;

    private String reqTime;

    private Integer type;

    private String deviceid;

    private Object data;

    RequestSocketModel(){}

    RequestSocketModel(Integer reqCode, String reqTime, Integer type){
        this.reqCode = reqCode;
        this.reqTime = reqTime;
        this.type = type;
    }

    RequestSocketModel(Integer reqCode, String reqTime, Integer type, Object data){
        this.reqCode = reqCode;
        this.reqTime = reqTime;
        this.type = type;
        this.data = data;
    }

    public static RequestSocketModel build(Integer type){
        return new RequestSocketModel(RandomUtils.nextInt(), "", type);
    }

    public static RequestSocketModel build(Integer reqCode, Integer type){
        return new RequestSocketModel(reqCode, DateUtils.dateToStringFormat(new Date(), DateUtils.YYYY_MM_DD_HH_MM_SS), type);
    }

    public static <T> RequestSocketModel build(Integer type, T data){
        return new RequestSocketModel(RandomUtils.nextInt(), DateUtils.dateToStringFormat(new Date(), DateUtils.YYYY_MM_DD_HH_MM_SS), type, data);
    }

    public static <T> RequestSocketModel build(Integer reqCode, Integer type, T data){
        return new RequestSocketModel(reqCode, DateUtils.dateToStringFormat(new Date(), DateUtils.YYYY_MM_DD_HH_MM_SS), type, data);
    }
}
